package com.gxa.upload.controller;

import com.gxa.log.cofig.OperateLogConfig;
import com.gxa.upload.service.UploadService;
import dto.ResultDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping(value = "upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@Api(tags = "上传文件")
public class UploadController {

    @Autowired
    private UploadService uploadService;

    @PostMapping("do")
    @ApiOperation(value = "上传文件的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name="file",value="文件对象",required = true),
            @ApiImplicitParam(name="uploadPath",value="保存路径",required = true),
    })
    public ResultDTO upload(MultipartFile file) throws IOException {
        return uploadService.upload(file);
    }
}
